package com.wtwd.device.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wtwd.device.dao.GroupDialMapper;
import com.wtwd.device.model.entity.GroupDial;
import com.wtwd.device.service.GroupDialService;
import com.wtwd.device.service.GroupLanguageService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zdl
 * @since 2023-01-03
 */
@Service
public class GroupDialServiceImpl extends ServiceImpl<GroupDialMapper, GroupDial> implements GroupDialService {

    @Resource
    private GroupDialMapper groupDialMapper;

    @Resource
    private GroupLanguageService groupLanguageService;


    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean bathInsertOrUpdate(List<GroupDial> groupDials) {
        if (groupDials == null || groupDials.size() == 0) {
            return false;
        }
        return groupDialMapper.bathInsertOrUpdate(groupDials) > 0 ? true : false;
    }

    @Override
    public boolean deleteGroupDial(Integer groupId, Integer dialId) {
        if (groupId == null || dialId == null) {
            return false;
        }
        return groupDialMapper.deleteGroupDial(groupId, dialId) > 0 ? true : false;
    }


    @Override
    public boolean deleteByGroupId(Integer groupInfoId) {
        if (groupInfoId == null) {
            return false;
        }
        return groupDialMapper.deleteByGroupId(groupInfoId) > 0 ? true : false;
    }

    @Override
    public List<GroupDial> getGroupDialByDialId(Integer dialId) {
        return new LambdaQueryChainWrapper<>(groupDialMapper)
                .eq(GroupDial::getDialId, dialId)
                .list();
    }

    @Override
    public boolean bathDelGroupDial(List<GroupDial> delGroupDial) {
       return groupDialMapper.bathDelGroupDial(delGroupDial)>0?true:false;
    }

}
